<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page language="java" import="java.util.*" %>
<jsp:directive.page import="com.xr.common.CommUtil"/>
<jsp:directive.page import="com.bstek.dorado.data.db.*"/>
<jsp:directive.page import="com.bstek.dorado.utils.variant.VariantSet"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title></title>
<script language="javascript" src="<%=request.getContextPath()%>/dorado/smartweb2.loadUserLib.d?file=/lib/jquery1.8.2.min.js"></script>
 <script  src="<%=request.getContextPath()%>/dorado/smartweb2.loadUserLib.d?file=/lib/highcharts2.3.5.js"></script>
<script   src="<%=request.getContextPath()%>/dorado/smartweb2.loadUserLib.d?file=/lib/exporting2.3.5.js"></script>
<script type="text/javascript"> 
		 	<%
		int cmc=0;
		String y="",x="",sql="";
		int startYear=Integer.parseInt( request.getParameter("FROM_DATE"));
		int endYear=Integer.parseInt(request.getParameter("TO_DATE"));
		int sum=0;
		String comId=request.getParameter("comId");
			DBStatement dbs=new  DBStatement();
			sql=" select nian, (select count(distinct oos.onoff_station_id)  from org_onoff_station oos"+
			 " where (oos.status in (2, 3) or oos.work_end_date is null) "+
  "and ((oos.work_start_date between to_date(nian || '0101', 'yyyyMMdd') and to_date(nian || '1231', 'yyyyMMdd') "+
  "or decode(oos.work_end_date, null, sysdate + 31, oos.work_end_date) between to_date(nian || '0101', 'yyyyMMdd') and to_date(nian || '1231', 'yyyyMMdd'))"+
  
  "or (to_date(nian || '0101', 'yyyyMMdd') between oos.work_start_date and oos.work_end_date "+
  "or to_date(nian || '1231', 'yyyyMMdd') between oos.work_start_date and decode(oos.work_end_date, null, sysdate + 31, oos.work_end_date))"+
"))renshu from (select "+startYear+"+(level-1) nian from dual connect by level<=("+(endYear-startYear)+") +1)";
 
//if(comId!=null || !comId.equals("null"))
//sql+=" and exists (select 1 from org_company com where com.dr=0 and oos.company_id=com.company_id  start with com.company_id="+comId+" CONNECT BY prior  com.company_id=com.super_company_id) ";
			dbs.setSql(sql);
			List list=dbs.queryForList();
			if(list.size()==0){out.write("</script><body>该公司无数据被统计！<body>"); return;}
			for(int i=0;i<list.size();i++){
			  VariantSet vs=(VariantSet)list.get(i);
			    
	 
		//	  System.out.println(vs.getInt(0)*100/93);
			   x+="'"+vs.getString("nian")+"',";
			   y+=""+vs.getString("renshu")+",";
			   
			}
			dbs.close();
			x=x.substring(0,x.length()-1); 
			y=y.substring(0,y.length()-1); 
			
		%>
		
		var chart;
			$(document).ready(function() {
				chart = new Highcharts.Chart({
					chart: {
						renderTo: 'container',
						defaultSeriesType: 'column',
						margin: [ 50, 50, 100, 80]
					},
					title: {
						text: '企业员工规模'
					},
					xAxis: {
						categories: [
							<%=x%>
						],
						labels: {
							rotation: -45,
							align: 'right',
							style: {
								 font: 'normal 13px Verdana, sans-serif'
							}
						}
					},
					yAxis: {
						min: 0,
						title: {
							text: '人员数量'
						}
					},
					legend: {
						enabled: false
					},
					tooltip: {
						formatter: function() {
							return '在<b>'+ this.x +'年</b><br/>'+
								 '累计<b>'+ this.y +
								 '</b>人次';
						}
					},
				        series: [{
						name: 'Population',
						data: [<%=y%>],
						dataLabels: {
							enabled: true,
							rotation: -90,
							color: '#FFFFFF',
							align: 'right',
							x: -3,
							y: 10,
							formatter: function() {
								return this.y;
							},
							style: {
								font: 'normal 13px Verdana, sans-serif'
							}
						}			
					}]
				});
				
				
			});
		</script>

  </head>
  
  <body>
    <div id="container" style="width: 100%; height: 100%; margin: 0 auto"></div>

  </body>
</html>
